<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="user.score">
        {{info}}
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: "#app",
            data: {
                info: "",
                user: {
                    score: 100
                }
            },
            watch: {
                // user: {
                //     handler(newUser) {
                //         console.log(newUser.score)
                //         if(newUser.score < 60) {
                //             this.info = "成绩不合格"
                //         }else if(newUser.score >= 60 && newUser.score <= 80) {
                //             this.info = "成绩良好"
                //         }else {
                //             this.info = "成绩优秀"
                //         }
                //     },
                //     deep: true
                // }
                // 使用这种方式进行深度监听
                'user.score': {
                    handler(score) {
                        console.log(score)
                    }
                }
            }
        })
    </script>
</body>
</html>